﻿<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
	<?php $this->load->view('common/top', array('title' => 'SEWIKI - CREATE EDITION')); ?>
<script src="<?=base_url() . 'static/js/jquery.validate.js'?>" type="text/javascript"></script>
<script src="<?=base_url() . 'static/js/jquery.base64.plugin.js'?>" type="text/javascript"></script>
<script>
$().ready(function() {
	$("#create_edition_form_entity").validate({
		rules: {
			content: {
				required: true,
				minlength: 10
			},
			comment: {
				required: true,
				minlength: 10
			}
		},
		messages: {
			content: {
				required: "请输入版本内容",
				minlength: "版本内容至少包含10个字符"
			},
			comment: {
				required: "请输入注释",
				minlength: "注释内容至少包含10个字符"
			}
		}
	});
	
	$("#load_button").click(function(){
		$("#load_box").trigger('click').change(function(){
			var fobj = document.getElementById("load_box");
			if(fobj) {
				var file = fobj.files.item(0);
				if(file) {
					var filename = file.getAsDataURL();
					alert(filename);
					filename = filename.substring(23, filename.lenght);
					$("#edit_area").val($.base64Decode(filename));
				}
			}
		});
	});
});

</script>
	<body>
		<div id="container">
			<?php $this->load->view('common/header'); ?>
			<div id="content">
				<?php $this->load->view('common/menu'); ?>
				<div id="main">
					<div id="create_edition_form_title" class="title">
						为<?=$chapter['book']['title']?>的第<?=$chapter['number']?>章-<?=$chapter['title']?>创建新版本
					</div>
					<div id="create_edition_form" class="text_form">
						<?php echo form_open('', array('enctype' => 'multipart/form-data', 'id' => 'create_edition_form_entity')); ?>
							<table width="100%">
								<tr>
									<td>
										<?php echo form_label('内容', 'content') ?>
									</td>
								</tr>
								<tr>
									<td id="edit_box">
										<div>
											<input id="load_button" type="button" alt="导入本地文件" value="导入本地文件" />
											<input type="file" name="save_file" id="save_box" style="display:none" />
											<input type="file" name="load_file" id="load_box" style="display:none" />
											&nbsp;<span style="color:#666; font-size:12px">[导入本地文件时请采用UTF8编码]</span>
										</div>
										<?php echo form_textarea(array(
											'id'    => 'edit_area',
											'name'  => 'content',
											'style' => 'width:90%')) ?>
									</td>
								</tr>
								<tr>
									<td><?=form_label('公开程度', 'public_level') ?></td>
								</tr>
								<tr>
									<td>
										公开<?=form_radio(array('name' => 'public_level', 'value' => 1, 'checked' => '"checked"'))?>&nbsp;
										不公开<?=form_radio(array('name' => 'public_level', 'value' => 0))?>
									</td>
								</tr>
								<tr>
									<td><?php echo form_label('注释', 'comment') ?></td>
								</tr>
								<tr>
									<td><?php echo form_input(array(
										'name'  => 'comment',
										'style' => 'width:90%')) ?></td>
								</tr>
								<tr>
									<td align="center"><?php echo form_submit('submit', '创建新版本') ?></td>
								</tr>
							</table>
						<?php echo form_close(); ?>
					</div>
				</div>
			</div>
			<?php $this->load->view('common/footer'); ?>
		</div>
	</body>
</html>